#include "../3dparty/gtest-support.h"
#include "../include/sort.h"

TEST( InsertSortTestCast, SortTest )
{
    ElemType es0[] = { 4, 12, 34, 35, 44, 45, 100 };
    ElemType es1[] = { 34, 12, 4, 45, 35, 44, 100 };

    InsertSort( es1, ARRAYSIZE( es1 ) );
    EXPECT_EQ( TRUE, VectorEqual( es0, es1, ARRAYSIZE( es1 ) ) );
}

TEST( SelectSortTestCast, SortTest )
{
    ElemType es0[] = { 4, 12, 34, 35, 44, 45, 100 };
    ElemType es1[] = { 34, 12, 4, 45, 35, 44, 100 };

    SelectSort( es1, ARRAYSIZE( es1 ) );
    EXPECT_EQ( TRUE, VectorEqual( es0, es1, ARRAYSIZE( es1 ) ) );
}

TEST( BubbleSortTestCast, SortTest )
{
    ElemType es0[] = { 4, 12, 34, 35, 44, 45, 100 };
    ElemType es1[] = { 34, 12, 4, 45, 35, 44, 100 };

    BubbleSort( es1, ARRAYSIZE( es1 ) );
    EXPECT_EQ( TRUE, VectorEqual( es0, es1, ARRAYSIZE( es1 ) ) );
}

TEST( QuickSortTestCast, SortTest )
{
    ElemType es0[] = { 4, 12, 34, 35, 44, 45, 100 };
    ElemType es1[] = { 34, 12, 4, 45, 35, 44, 100 };

    QuickSort( es1, ARRAYSIZE( es1 ) );
    EXPECT_EQ( TRUE, VectorEqual( es0, es1, ARRAYSIZE( es1 ) ) );
}

TEST( HeapSortTestCast, SortTest )
{
    ElemType es0[] = { 4, 12, 34, 35, 44, 45, 100 };
    ElemType es1[] = { 34, 12, 4, 45, 35, 44, 100 };

    HeapSort( es1, ARRAYSIZE( es1 ) );
    EXPECT_EQ( TRUE, VectorEqual( es0, es1, ARRAYSIZE( es1 ) ) );
}